import * as ActionTypes from './ActionTypes.js';

const reducer = (state=[],action)=>{
    switch(action.type){
        // if(ActionTypes.ADD_TODO==='ADD_TODO'){
        //
        // }else if(ActionTypes.ADD_TODO==='REMOVE_TODO'){
        //
        // }else {
        //
        // }
        case ActionTypes.ADD_TODO :
            return [
                ...state,
                {
                    text:action.text,
                    id:action.id,
                    data:{}
                }
            ];
        case ActionTypes.REMOVE_TODO :
            return state.filter((todoItem) => {
				return todoItem.id !== action.id;
			});
        case ActionTypes.EDIT_TODO :
            state[action.id].data = action.data
            return state;
        default:
            return state;
    }
}
export default reducer;
